package com.lixin.smartclassroom.ui.home.tab1.activity

import com.drake.brv.utils.bindingAdapter
import com.drake.net.utils.scopeNetLife
import com.lixin.smartclassroom.api.courselist
import com.lixin.smartclassroom.bean.DataListBean
import com.lixin.smartclassroom.databinding.ActivityCourseRecommendBinding
import com.lixin.smartclassroom.databinding.ActivityMessageBinding
import com.lixin.smartclassroom.ui.home.adapter.courseRecommend
import com.lixin.smartclassroom.ui.home.adapter.messageList
import com.lixinkeji.base.BaseActivity
import com.lixinkeji.extension.gone
import com.lixinkeji.extension.visible

/**
 * Description 课程推荐
 * Author: lwc
 * Date:2023/12/6 10:41
 */
class CourseRecommendAct : BaseActivity<ActivityCourseRecommendBinding>() {
    override fun getViewBinding() = ActivityCourseRecommendBinding.inflate(layoutInflater)

    override fun topBarHide() = false
    override fun startPadding() = true
    private lateinit var listBean: ArrayList<DataListBean>
    override fun title() = "课程推荐"


    override fun iniView() {

        binding.recycler.courseRecommend()

        binding.apply {
            refresh.onRefresh {
                scopeNetLife {
                    val baseBean = courselist(index, 10, "2")
                    listBean = baseBean.dataList!!
                    addData(listBean) {
                        if (binding.recycler.bindingAdapter.models?.size == 0) {
                            binding.state.showEmpty()
                            binding.recycler.gone()
                        } else {
                            binding.recycler.visible()
                        }
                        listBean.size == 10&& baseBean.totalPage!! >index
                    }
                }
            }.autoRefresh()
        }
    }

}